package com.bob.demo.system.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.bob.demo.system.model.User;

public interface UserRepository extends JpaRepository<User, String> {
	
	//利用原生的SQL进行查询操作  
	   @Query(value = "select u.* from user u where  u.username=?1", nativeQuery = true)  
	   @Modifying  
	   public List<User> findUserByName(String name);  
	   
	   @Transactional
	   @Modifying
	   @Query("delete from User where id = ?1")
	   void deleteByUserId(String id);
	   
	   @Transactional(timeout = 10)
	   @Query("select u from User u where u.id = ?1")
	   User findUserById(String id);
}
